/** 
 * ENGLISH AREA UNITS
 * Contains SQUAREINCHES, SQUAREFEET, SQUAREYARDS, ACRES, SQUAREMILES
 * METRIC BASE: SQUAREMETERS
 * Each unit is set up as:
 * 
 * UNITS {
 * 
 * 	-- Returns value in same units --
 * 	public double toUnits(double value){
 * 		return value;
 * 	}
 * 
 * 	-- Returns value in other units --
 * 	-- One method for each type in category --
 * 	-- Example: UNITS = INCHES, value = 18, Convert toFeet, Return = 1.5 (Feet)
 * 	public double toOtherUnits(double value){
 * 		return value ( / or * ) ####;
 * 	}
 * 		
 * 	-- Converts value value of Unit type sourceUnit into UNITS type --
 * 	-- Example: UNITS = INCHES, value = 1.5, sourceUnit = FEET, return = 18 (Inches)
 * 	public double convert (double value, EnglishUnit sourceUnit){
 * 		return sourceUnit.toUnits(value);
 *	}
 * }
 */

package umuc.cmsc495.mach2.unit.english;

/**
 * @author Michael Swann
 */
public enum EnglishAreaUnit {
    SQUAREINCHES {
	@Override
	public double toSquareInches(double value) {
	    return value;
	}

	@Override
	public double toSquareFeet(double value) {
	    return value / 144;
	}

	@Override
	public double toSquareYards(double value) {
	    return value / 1296;
	}

	@Override
	public double toAcres(double value) {
	    return value / 6272640;
	}

	@Override
	public double toSquareMiles(double value) {
	    return value / 4014489600D;
	}

	@Override
	public double toSquareMeters(double value) {
	    return value / 1550.0031;
	}

	@Override
	public double convert(double value, EnglishAreaUnit sourceUnit) {
	    return sourceUnit.toSquareInches(value);
	}
    },

    SQUAREFEET {
	@Override
	public double toSquareInches(double value) {
	    return value * 144;
	}

	@Override
	public double toSquareFeet(double value) {
	    return value;
	}

	@Override
	public double toSquareYards(double value) {
	    return value / 9;
	}

	@Override
	public double toAcres(double value) {
	    return value / 43560;
	}

	@Override
	public double toSquareMiles(double value) {
	    return value / 27878400;
	}

	@Override
	public double toSquareMeters(double value) {
	    return value / 10.7639104;
	}

	@Override
	public double convert(double value, EnglishAreaUnit sourceUnit) {
	    return sourceUnit.toSquareFeet(value);
	}
    },

    SQUAREYARDS {
	@Override
	public double toSquareInches(double value) {
	    return value * 1296;
	}

	@Override
	public double toSquareFeet(double value) {
	    return value * 9;
	}

	@Override
	public double toSquareYards(double value) {
	    return value;
	}

	@Override
	public double toAcres(double value) {
	    return value / 4840;
	}

	@Override
	public double toSquareMiles(double value) {
	    return value / 3097600;
	}

	@Override
	public double toSquareMeters(double value) {
	    return value / 1.19599005;
	}

	@Override
	public double convert(double value, EnglishAreaUnit sourceUnit) {
	    return sourceUnit.toSquareYards(value);
	}
    },

    ACRES {
	@Override
	public double toSquareInches(double value) {
	    return value * 6272640;
	}

	@Override
	public double toSquareFeet(double value) {
	    return value * 43560;
	}

	@Override
	public double toSquareYards(double value) {
	    return value * 4840;
	}

	@Override
	public double toAcres(double value) {
	    return value;
	}

	@Override
	public double toSquareMiles(double value) {
	    return value / 640;
	}

	@Override
	public double toSquareMeters(double value) {
	    return value * 4046.85642;
	}

	@Override
	public double convert(double value, EnglishAreaUnit sourceUnit) {
	    return sourceUnit.toAcres(value);
	}
    },

    SQUAREMILES {
	@Override
	public double toSquareInches(double value) {
	    return value * 4014489600D;
	}

	@Override
	public double toSquareFeet(double value) {
	    return value * 27878400;
	}

	@Override
	public double toSquareYards(double value) {
	    return value * 3097600;
	}

	@Override
	public double toAcres(double value) {
	    return value * 640;
	}

	@Override
	public double toSquareMiles(double value) {
	    return value;
	}

	@Override
	public double toSquareMeters(double value) {
	    return value * 2589988.11;
	}

	@Override
	public double convert(double value, EnglishAreaUnit sourceUnit) {
	    return sourceUnit.toSquareMiles(value);
	}
    };

    /**
     * @param sourceValve
     *            Value in Source Units
     * @param sourceUnit
     *            Source Unit Type
     * @return Value in Target Units
     */
    public abstract double toSquareInches(double value);

    public abstract double toSquareFeet(double value);

    public abstract double toSquareYards(double value);

    public abstract double toAcres(double value);

    public abstract double toSquareMiles(double value);

    public abstract double toSquareMeters(double value);

    public abstract double convert(double sourceValve, EnglishAreaUnit sourceUnit);
}